<%@ page pageEncoding="UTF-8"%>
<%@ include file="../common/global.jsp"%>

<!DOCTYPE html>
<html>
<head>
<%@ include file="../common/meta.jsp"%>
<title><f:message key="common.title" /> - <f:message key="product" /></title>
<%@ include file="../common/css.jsp"%>
</head>
<body>
<%@ include file="../common/header.jsp"%>

	<div class="container">
		<div class="row">
			<div class="panel panel-default">
				<div class="panel-heading">
					<f:message key="user.create_user" />
				</div>
				<div class="panel-body">
					<form role="form" id="user_create_form" >
                            <div class="form-group">
                                <label for="username"><f:message key="user.username"/>:</label>
                                <input type="text" id="username" name="username" class="ext-required">
                            </div>

                            <div class="form-group">
                                <label for="password"><f:message key="user.password"/>:</label>
                                <input type="text" id="password" name="password" class="ext-required">
                            </div>

                            <div class="form-group">
                                <button type="submit" class="btn btn-default">
                                    <f:message key="common.save" />
                                </button>
                                <button type="button" id="back" class="btn btn-default">
                                    <f:message key="common.back" />
                                </button>
                            </div>
					</form>
				</div>
			</div>
			<!-- end of panel -->
		</div>
	</div>

	<%@ include file="../common/footer.jsp"%>
	<%@ include file="../common/js.jsp"%>
	<script type="text/javascript">
        $(function() {
            $('#user_create_form').ajaxForm({
                type: 'post',
                url: BASE + '/user',
                dataType: 'json',
                beforeSubmit: function() {
                    return Smart.Validator.checkRequired('user_create_form');
                },
                success: function(result) {
                    if (result.success) {
                        location.href = BASE + '/users';
                    }
                }
            });

            $('#back').click(function() {
                history.back();
            });
        });
	</script>
</body>
</html>